import { createRouter, createWebHistory } from 'vue-router'
import home from '@/views/home.vue'
import type { RouteRecordRaw } from 'vue-router';

export const staticRouter: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: 'login',
    meta: {
      showRoute: false
    }
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/index.vue'),
    meta: {
      showRoute: false
    }
  },
  {
    path: '/home',
    name: 'home',
    component: home,
    meta: {
      showRoute: true,
      title: '个人中心'
    }
  },
  {
    path: '/404',
    component: () => import('../views/404.vue'),
    meta: {
      showRoute: false
    }
  }

]


export const dynamicRouter: RouteRecordRaw[] = [
  {
    path: '/system',
    name: 'system',
    meta: {
      showRoute: true,
      title: '系统管理'
    },
    children: [
      {
        path: '/system/log',
        name: 'log',
        component: () => import('../views/system/log.vue'),
        meta: {
          showRoute: true,
          title: '日志管理'
        },
      },
      {
        path: '/system/user',
        name: 'user',
        component: () => import('../views/system/user.vue'),
        meta: {
          showRoute: true,
          title: '用户管理',
          roles: [0]
        },
      }
    ]
  },

  {
    path: "/:catchAll(.*)",
    redirect: '/404',
    meta: {
      showRoute: false
    }
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: staticRouter
})


export default router
